;; lang3-2

(module tests mzscheme
  
  (provide test-list)
  ;;;;;;;;;;;;;;;; tests ;;;;;;;;;;;;;;;;
  
  (define test-list
    '(
      (positive-const "11" 11)
      (negative-const "-33" -33)
      (simple-arith-1 "-(44,33)" 11)

      (nested-arith-left "-(-(44,33),22)" -11)
      (nested-arith-right "-(55, -(22,11))" 44)
  

      (test-var-1 "x" 10)
      (test-var-2 "-(x,1)" 9)
      (test-var-3 "-(1,x)" -9)
      
      (test-unbound-var-1 "foo" error)
      (test-unbound-var-2 "-(x,foo)" error)
  
      (multi-exp-test-1 "m(2,3)" 6)
      (multi-exp-test-2 "m(3,-(5,1))" 12)
      
      (explicit-ref-test "let i = newref(33) in deref(i)" 33)
      
      (assignment-test "let x = newref(23) 
                          in begin setref(x,33); deref(x) end"
                         33)
      
      (begin-exp-test-1 "begin -(-(44,11),3); 1; 2 end " 2)
      
      (begin-exp-test-2 
        "let g = let counter = newref(0) 
         in proc (dummy) begin
                           setref(counter, -(deref(counter),-1));
                           deref(counter)
                         end
 in -((g 11),(g 22))"
        -1)
      
      
      (Exp-REF-test3 
"let g = let counter = newref(0) 
         in proc (dummy) begin
                           setref(counter, -(deref(counter),-1));
                           deref(counter)
                         end
 in -((g 11),(g 22))"
       -1)

       (show-allocation-1 "
let x = newref(22)
in let f = proc (z) let zz = newref(-(z,deref(x))) in deref(zz)
   in -((f 66), (f 55))" 11)

      (apply-proc-in-rator-pos "(proc(x) -(x,1)  30)" 29)
       
      (let-to-proc-1 "(proc(f)(f 30)  proc(x)-(x,1))" 29)

      (nested-procs "((proc (x) proc (y) -(x,y)  5) 6)" -1)
      
    (twice "
        (proc (twice)
           ((twice proc (z) -(z,1)) 11)
         proc (f) proc (x) (f (f x)))"
      9)
    ))
  )